package com.kjj.car.service.impl;

import com.kjj.car.domain.CarResources;
import com.kjj.car.mapper.CarResourcesMapper;
import com.kjj.car.service.ICarResourcesService;
import com.kjj.basic.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author kan
 * @since 2022-09-08
 */
@Service
public class CarResourcesServiceImpl extends BaseServiceImpl<CarResources> implements ICarResourcesService {

    @Autowired
    private CarResourcesMapper carResourcesMapper;
    @Override
    public void addOrUpdate(CarResources carResources) {
        Long carId = carResources.getCarId();
        //无论是否有都删除原来
        carResourcesMapper.removeByCardId(carId);

        //在添加新的
        carResourcesMapper.save(carResources);
    }

    @Override
    public void delByCarId(Long id) {
        carResourcesMapper.removeByCardId(id);
    }
}
